<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container">
      <div v-for="item in crud.data" :key="item.index">
        <div v-if="item.isAdmin === 0">
          <div>{{ item.name }}</div>
          <panel-group :group-id="item.id" :group-name="item.name" @handleSysData="handleSysData" />
        </div>
      </div>
    </div>
    <!--
    <el-dialog
      title="子系统"
      :visible.sync="dialogVisible"
      width="60%"
    >
      <span>
        <system-group :project-id="projectId"/>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
-->
  </div>

</template>

<script>
import PanelGroup from './dashboard/PanelGroup'
import crudDept from '@/api/system/dept'
import CRUD, { presenter, header, crud } from '@crud/crud'

export default {
  name: 'Dashboard',
  components: {
    PanelGroup
  },
  mixins: [presenter(), header(), crud()],
  cruds() {
    return CRUD(
      { title: '项目', url: 'api/dept', sort: 'id,desc', crudMethod: { ...crudDept }, query: { pid: null }}
    )
  },
  data() {
    return {
      dialogVisible: false,
      sysMsg: [],
      projectId: ''
    }
  },
  mounted() {
  },
  methods: {
    handleSysData(projectId) {
      this.projectId = projectId
      this.dialogVisible = true
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .dashboard-editor-container {
    padding: 32px;
    background-color: rgb(240, 242, 245);
    position: relative;

    .github-corner {
      position: absolute;
      top: 0;
      border: 0;
      right: 0;
    }

    .chart-wrapper {
      background: #fff;
      padding: 16px 16px 0;
      margin-bottom: 32px;
    }
  }

  @media (max-width: 1024px) {
    .chart-wrapper {
      padding: 8px;
    }
  }
</style>
